<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link href="./resources/css/default.css" rel="stylesheet"
		type="text/css" />
	<link href="./resources/css/cssLayout.css" rel="stylesheet"
		type="text/css" />
	<title>Sabatec Manutenção &amp; Construção Civil</title>
	<script type="text/javascript">
		function handleLoginRequest(xhr, status, args) {
			if (args.validationFailed || !args.loggedIn) {
				PF('dlg').jq.effect("shake", {
					times : 5
				}, 100);
			} else {
				PF('dlg').hide();
				$('#loginLink').fadeOut();
			}
		}
	</script>
	<script type="text/javascript">
		function handleComplete(args) {
			//alert(args.error);  
			if (!args.error) {
				dlg2.show();
			}

		}
	</script>
</h:head>

<h:body>

	<div id="top">
		<ui:insert name="top">
			<ui:insert name="top">
				<center>
					<img src="img/logo_sabate.jpg" width="740" height="266"
						alt="logo_sabate" />
				</center>
			</ui:insert>
		</ui:insert>
	</div>

	<div id="content" class="center_content">
		<ui:insert name="content">
			<h:form id="formTop">
				<p:growl id="growl" showDetail="true" life="4000" />
				<p:breadCrumb>
					<p:menuitem value="home" url="index.xhtml" />
					<p:menuitem value="Cadastro de Serviço" url="cadastraServico.xhtml" />
				</p:breadCrumb>

				<div align="center">
					<p:panelGrid columns="10">


						<f:facet name="header">  
                            Cadastro de Recurso 
                     </f:facet>

						<h:outputLabel value="ID: " style="font-weight: bold" />
						<p:outputLabel value="#{obraExcecSabatecBean.requestService.id}" />

						<h:outputLabel value="Cliente: " style="font-weight: bold" />
						<p:outputLabel
							value="#{obraExcecSabatecBean.requestService.cliente}" />

						<h:outputLabel value="Emprendimento: " style="font-weight: bold" />
						<p:outputLabel
							value="#{obraExcecSabatecBean.requestService.emprendimento}" />

						<h:outputLabel value="Torre: " style="font-weight: bold" />

						<p:outputLabel
							value="#{obraExcecSabatecBean.requestService.torre}" />

						<h:outputLabel value="Unidade: " style="font-weight: bold" />
						<p:outputLabel
							value="#{obraExcecSabatecBean.requestService.unidade}" />

						<f:facet name="footer">
						</f:facet>
					</p:panelGrid>
				</div>


				<p:panelGrid columns="2" style="width: 100%">

					<h:outputLabel value="Nome: *" />
					<p:inputText value="#{obraExcecSabatecBean.obraExecSabatec.nome}" />
					
					<h:outputLabel value="Função: *" />
					<p:inputText value="#{obraExcecSabatecBean.obraExecSabatec.funcao}" />

					<h:outputLabel value="Hora Trabalhada: *" />
					<p:inputText value="#{obraExcecSabatecBean.obraExecSabatec.horat}" />

					<h:outputLabel value="Data: *" />
					<p:calendar value="#{obraExcecSabatecBean.obraExecSabatec.data}"
						id="popupButtonCal" showOn="button" />

					<f:facet name="footer">
						<center>
							<p:commandButton value="Salvar" ajax="true" icon="ui-icon-disk"
								action="#{obraExcecSabatecBean.salva(obraExcecSabatecBean.obraExecSabatec)}"
							update=":form:tbl :form:growl" style="margin:0;" />
						</center>
					</f:facet>
				</p:panelGrid>

			</h:form>

			<h:form id="form">
			<p:growl id="growl" showDetail="true" life="4000" />
				<p:dataTable var="obraList" id="tbl"
					value="#{obraExcecSabatecBean.obras}" paginator="true" rows="5">
					<p:growl id="growl" showDetail="true" life="4000" />
					<p:column>
						<f:facet name="header">
							<h:outputText value="ID" />
						</f:facet>
						<h:outputText value="#{obraList.id}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Nome" />
						</f:facet>
						<h:outputText value="#{obraList.nome}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Função" />
						</f:facet>
						<h:outputText value="#{obraList.funcao}" />
					</p:column>

					<p:column>
					
						<f:facet name="header">
							<h:outputText value="Hora Trabalhada" />
						</f:facet>
						<h:outputText value="#{obraList.horat}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Data" />
						</f:facet>
						<h:outputText value="#{obraList.data}">
							<f:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputText>
					</p:column>
					
					
					<p:column>
						<f:facet name="header">
							<h:outputText value="Ações" />
						</f:facet>
						
						<p:commandButton id="selectButton" update=":form:display"
							oncomplete="handleComplete(args)" icon="ui-icon-pencil" >
							<f:setPropertyActionListener
								target="#{obraExcecSabatecBean.obraExecSabatec}"
								value="#{obraList}" />
						</p:commandButton>
						
					<p:commandButton ajax="true"
							action="#{obraExcecSabatecBean.exclui(obraList)}"
							icon="ui-icon-trash" update=":form:tbl :form:growl" />
					</p:column>
				</p:dataTable>
				
				<p:dialog id="content" header="Editando Informação" modal="true"
					widgetVar="dlg2" height="auto" draggable="false" width="auto%"
					closable="true">
					<h:panelGrid id="display" columns="1" cellpadding="2"
						style="margin:0 auto;">
						<p:column>
							<h:inputHidden
								value="#{obraExcecSabatecBean.obraExecSabatec.id}" />
						</p:column>
						<p:column>
							<h:outputText value="Nome: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{obraExcecSabatecBean.obraExecSabatec.nome}" />
						</p:column>
						<p:column>
							<h:outputText value="Função: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{obraExcecSabatecBean.obraExecSabatec.funcao}" />
						</p:column>
						<p:column>
							<h:outputText value="Hora Trabalhada: " />
						</p:column>
						<p:column>
							<p:inputText
								value="#{obraExcecSabatecBean.obraExecSabatec.horat}" />
						</p:column>
						<p:column>
							<h:outputText value="Data: " />
						</p:column>
						<p:column>
							<p:calendar
								value="#{obraExcecSabatecBean.obraExecSabatec.data}"
								id="popupButtonCal" showOn="button" />
						</p:column>
						
						<p:commandButton icon="ui-icon-disk" ajax="true"
							action="#{obraExcecSabatecBean.salvaUpdate(obraExcecSabatecBean.obraExecSabatec)}"
							update=":form:tbl :form:growl" />

					</h:panelGrid>
				</p:dialog>

			</h:form>
			<h:form>
				<center>
					<h:panelGrid columns="1">
						<p:panel header="Exportar Serviços Excel">
							<center>
								<h:commandLink>
									<p:graphicImage value="img/csv.png" />
									<p:dataExporter type="xls" target="tbl" fileName="servicos" />
								</h:commandLink>
								<h:commandLink>
									<p:graphicImage value="img/pdf.png" />
									<p:dataExporter type="pdf" target="tbl" fileName="servicos" />
								</h:commandLink>
							</center>
						</p:panel>
					</h:panelGrid>
				</center>
			</h:form>
		</ui:insert>
	</div>

	<div id="bottom">
		<ui:insert name="bottom">
			<img src="img/background_bottom.jpg" width="6" height="30" />
		</ui:insert>
	</div>

</h:body>

</html>
